<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-menu"></i>{{$route.name}}
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div>
            <div class="handle-box">
            </div>
            <div>
                <el-table :data="users" border fit>
                    <el-table-column prop="" label="头像" align="center">
                        <template slot-scope="scope">
                            <img :src="scope.row.avatar" style="width:100%;height:100%" />
                        </template>
                    </el-table-column>
                    <el-table-column prop="nickname" label="昵称" align="center">
                    </el-table-column>
                    <el-table-column prop="phone" label="手机号" align="center">
                    </el-table-column>
                    <el-table-column prop="sex" label="性别" align="center">
                    </el-table-column>
                    <el-table-column prop="city" label="地区" align="center">
                    </el-table-column>
                    <!-- <el-table-column fixed="right" label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button @click="info(scope.row)">查看</el-button>
                        </template>
                    </el-table-column> -->
                </el-table>
            </div>
            <div class="block">
                <el-pagination @current-change="handleCurrentChange" :current-page="num" layout="total,  prev, pager, next, jumper" :total="totalElements">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
import { allUser, putUser } from '../../api/server.js'
export default {
    data() {
        return {
            users: [],
            num: 1,
            totalElements: 10
        }
    },
    created() {
        this.getAllUser(1, 10)
    },
    methods: {
        addMenu() {
            this.$router.push({
                path: '/menuAdd'
            })
        },
        handleCurrentChange(val) {
            this.num = val
            this.getAllUser(val, 10)
        },
        getAllUser(page, pageSize) {
            allUser({ page, pageSize })
                .then(res => {
                    this.users = res.result
                    this.totalElements = res.resultNum
                })
        }
    }
}

</script>
<style lang="scss" scoped>
.handle-box {
  margin-bottom: 1%;
  .search {
    width: 30%;
  }
}

.block {
  text-align: center;
  margin-top: 1%;
}
</style>